package com.hainingtong.user.util;

import lombok.Getter;

/**
 * 整体错误码规则如下
 * 1. 从2000开始，前面2位表示大模块错误，后面2位表示小模块错误
 */
@Getter
public enum ResultCode {

    // 正确就返回2000
    SUCCESS(true,2000,"成功"),


    // 公共的错误用2001~2099来表示
    ERROR_AUTH_CODE(false,2001,"验证码错误"),
    UNKNOWN_REASON(false,2002,"未知错误"),
    PARAM_ERROR(false,2003,"参数不正确"),
    NO_PERMISSION(false, 2004, "无权限"),
    NOT_AUTH(false, 2005, "未登录"),
    PHONE_CODE_EXISTS(false, 2006, "手机验证码已发送，等下再尝试"),
    CREATE_CAPTCHA_ERROR(false, 2007, "生成图形验证码出错"),


    // 2100~2199表示用户相关的
    SUCCESS_LOGIN(true,2000,"登陆成功"),
    SUCCESS_REGISTER(true,2000,"注册成功"),
    ERROR_NOT_EXISTS_NICKNAME(false,2107,"昵称不存在"),
    ERROR_PASSWORD(false,2108,"密码错误"),
    ERROR_NOT_LOGGED_IN(false,2109,"账号未登录"),
    ERROR_NO_PERMISSION(false,2110,"没有权限"),
    ERROR_NICKNAME_EXISTS(false,2111,"昵称已存在"),
    ERROR_PRINCIPAL_EXISTS(false,2112,"账号已存在"),
    ERROR_PRINCIPAL_NOT_EXISTS(false,2113,"账号不存在"),
    ERROR_LOGIN_TYPE_INVALID(false,2114,"不支持该用户类型"),
    ERROR_PHONE_CODE_INVALID(false,2115,"短信验证码错误"),
    ERROR_TOKEN_INVALID(false,2116,"登录已过期，请重新登录"),
    ERROR_USER_DISABLED(false,2117,"该用户已被禁用");


    private final Boolean status; //响应是否成功
    private final Integer code; //返回码
    private final String message; //返回消息

    ResultCode(Boolean status, Integer code, String message) {
        this.status = status;
        this.code = code;
        this.message = message;
    }
}
